package com.atguigu.r2dbc.repository;

import com.atguigu.r2dbc.entity.Author;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.r2dbc.repository.R2dbcRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;

import java.util.Collection;

/**
 * @author Jungle
 * @create 2024-01-16 11:37
 * 写 AuthorRepositories 接口
 */
@Repository
public interface AuthorRepository extends R2dbcRepository<Author,Long> {

    //默认继承了一堆CRUD方法像mybatis-plus

    //QBC:Query By Criteria
    // QBE:Query By Example

    //成为一个起名工程师 where id In () and name ike ?
    // 仅仅限制单表复杂查询
    Flux<Author> findAllByIdInAndNameLike(Collection<Long> id, String name);

    // 多表复杂查询
    @Query("select * from t_author")
    Flux<Author> findHaha();

    //     1-1 ：关联
    //     1-N: 关联
    //     场景
    // 1、一个图书有唯一作者; 1-1
    // 2、一个作者可以有很多图书: 1-N

}
